package com.ljw.spring.annotation.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.*;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

/**
 * @FileName Computer
 * @Description TODO
 * @Author ljw
 * @Date 2021/2/3 2:27
 * @Version 1.0
 */
@Component
public class Computer implements ApplicationContextAware,BeanNameAware,EmbeddedValueResolverAware,MessageSourceAware{
    @Override
    public void setBeanName(String name) {
        System.out.println("向IOC容器注册的组件名："+name);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("IOC容器："+applicationContext);
    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver resolver) {
        String s = resolver.resolveStringValue("解析占位符：#{2+8}，${os.name}");
        System.out.println("解析结果："+s);
    }

    @Override
    public void setMessageSource(MessageSource messageSource) {
        System.out.println("被对象用的消息源："+messageSource);
    }
}
